namespace CampWeek5__Book_Project_.Data.Migrations
{
    using System;
    using System.Data.Entity.Migrations;

    public partial class added_Tag_class : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.Author_Tags",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        AuthorId = c.Int(nullable: false),
                        TagId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Authors", t => t.AuthorId, cascadeDelete: false)
                .ForeignKey("dbo.Tags", t => t.TagId, cascadeDelete: false)
                .Index(t => t.AuthorId)
                .Index(t => t.TagId);

            CreateTable(
                "dbo.Book_Tags",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        BookId = c.Int(nullable: false),
                        TagId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Books", t => t.BookId, cascadeDelete: false)
                .ForeignKey("dbo.Tags", t => t.TagId, cascadeDelete: false)
                .Index(t => t.BookId)
                .Index(t => t.TagId);

            CreateTable(
                "dbo.Tags",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Description = c.String(),
                    })
                .PrimaryKey(t => t.Id);

            DropColumn("dbo.Authors", "Style");
            DropColumn("dbo.Books", "Genre");
        }

        public override void Down()
        {
            AddColumn("dbo.Books", "Genre", c => c.String());
            AddColumn("dbo.Authors", "Style", c => c.String());
            DropForeignKey("dbo.Book_Tags", "TagId", "dbo.Tags");
            DropForeignKey("dbo.Author_Tags", "TagId", "dbo.Tags");
            DropForeignKey("dbo.Book_Tags", "BookId", "dbo.Books");
            DropForeignKey("dbo.Author_Tags", "AuthorId", "dbo.Authors");
            DropIndex("dbo.Book_Tags", new[] { "TagId" });
            DropIndex("dbo.Book_Tags", new[] { "BookId" });
            DropIndex("dbo.Author_Tags", new[] { "TagId" });
            DropIndex("dbo.Author_Tags", new[] { "AuthorId" });
            DropTable("dbo.Tags");
            DropTable("dbo.Book_Tags");
            DropTable("dbo.Author_Tags");
        }
    }
}